<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
            background: skyblue;
            position: absolute;
            left: 0px;
            top: 30px;
        }
        @keyframes move{
            0%{
                left:0px;
            }
            100%{
                left:300px;
            }
        }
    </style>
</head>
<body>
    <button>点击</button>
    <div class="box"></div>
    <script>
        var oBtn=document.querySelector("button");
        var oBox=document.querySelector(".box");
        oBtn.onclick=function(){
            oBox.style.animation="move 2s forwards";
        }

        oBox.addEventListener("animationstart",function(){
            console.log("动画开始了");
        })
        oBox.addEventListener("animationend",function(){
            alert("动画结束了");
        })
    </script>
</body>
</html>